﻿/**
* oTested - source + widget
* $Tested - resultDOM + widget
*/
function getStandartTests()
{
	var aTests = new TestSiute();
	var unitTest = function GetItemsFromSelect(oTested)
	{
		var oResult = new TestResult();
		var aMustVals = [];
		var aActualVals = [];

		$('#example').children('option').each(function (index) { aMustVals.push(this.value.toString()); });
		var id = oTested.attr('id');
		$('#' + id).find('li').each(function (index) { aActualVals.push($(this).data('value').toString()); });

		oResult.title = 'Get ITEMs from SELECT';
		oResult.must = aMustVals;
		oResult.actual = aActualVals;
		return oResult;
	};
	aTests.push(unitTest);

	unitTest = function GetAttrsFromOption(oTested)
	{
		var oResult = new TestResult();
		var aMustVals = [];
		var aActualVals = [];

		$('#example').children('option').each(function (index)
		{
			aMustVals.push(this.value.toString());
			aMustVals.push($(this).text());
		});
		var id = oTested.attr('id');
		$('#' + id).find('li').each(function (index)
		{
			var $obj = $(this);
			aActualVals.push($obj.data('value').toString());
			aActualVals.push($obj.data('filter').toString());
		});

		oResult.title = 'Get ATTRs from OPTION';
		oResult.must = aMustVals;
		oResult.actual = aActualVals;
		return oResult;
	};
	aTests.push(unitTest);

	unitTest = function ExtendedOptionTemplate(oTested)
	{
		var oResult = new TestResult();
		var aMustVals = [];
		var aActualVals = [];

		$('#example').children('option').each(function (index)
		{
			aMustVals.push($(this).data('group').toString());
		});
		var id = oTested.attr('id');
		$('#' + id).find('li').each(function (index)
		{
			aActualVals.push($(this).data('group').toString());
		});

		oResult.title = 'Extended Option Template';
		oResult.must = aMustVals;
		oResult.actual = aActualVals;
		return oResult;
	};
	aTests.push(unitTest);

	unitTest = function StandartSelectProperties(oTested)
	{
		var oResult = new TestResult();
		var oMustVals = {};
		var oActualVals = {};

		domSelect = document.getElementById('example');
		oMustVals['selectedIndex'] = domSelect.selectedIndex;
		oMustVals['value'] = domSelect.options[domSelect.selectedIndex].value;
		oMustVals['length'] = domSelect.length;
		oMustVals['size'] = domSelect.size;
		oMustVals['type'] = domSelect.type;
		oMustVals['name'] = domSelect.name;

		oActualVals['selectedIndex'] = oTested.jqcmbx('selectedIndex');
		oActualVals['value'] = oTested.jqcmbx('value');
		oActualVals['length'] = oTested.jqcmbx('length');
		oActualVals['size'] = oTested.jqcmbx('size'); ;
		oActualVals['type'] = oTested.jqcmbx('type');
		oActualVals['name'] = oTested.jqcmbx('name');

		oResult.title = 'Standart SELECT properties';
		oResult.must = oMustVals;
		oResult.actual = oActualVals;
		return oResult;
	};
	aTests.push(unitTest);

	unitTest = function StandartDOMSelectProperties(oTested)
	{
		var oResult = new TestResult();
		var oMustVals = {};
		var oActualVals = {};

		domSelect = document.getElementById('example');
		oMustVals['selectedIndex'] = domSelect.selectedIndex;
		oMustVals['length'] = domSelect.length;
		oMustVals['size'] = domSelect.size;
		oMustVals['type'] = domSelect.type;
		oMustVals['name'] = domSelect.name;

		var domObject = document.getElementById(oTested.attr('id'));
		oActualVals['selectedIndex'] = domObject.selectedIndex;
		oActualVals['length'] = domObject.length;
		oActualVals['size'] = domObject.size; ;
		oActualVals['type'] = domObject.type;
		oActualVals['name'] = domObject.name;

		oResult.title = 'Standart DOM SELECT properties';
		oResult.must = oMustVals;
		oResult.actual = oActualVals;
		return oResult;
	};
	aTests.push(unitTest);

	//unitTest = function StandartDOMOptionProperties(oTested)
	//{
	//	var oResult = new TestResult();
	//	var oMustVals = {};
	//	var oActualVals = {};

	//	domSelect = document.getElementById('example');
	//	oMustVals['options_value'] = domSelect.options[domSelect.selectedIndex].value;
	//	oMustVals['options_item'] = domSelect.options.item(0);
	//	oMustVals['options_named_item'] = domSelect.options.namedItem('self');

	//	var domObject = document.getElementById(oTested.attr('id'));
	//	oActualVals['options_value'] = domObject.options[domObject.selectedIndex].value;
	//	oActualVals['options_item'] = domObject.options.item(0);
	//	oActualVals['options_named_item'] = domObject.options.namedItem('self');

	//	oResult.title = 'Standart DOM OPTION properties';
	//	oResult.must = oMustVals;
	//	oResult.actual = oActualVals;
	//	return oResult;
	//};
	//aTests.push(unitTest);

	unitTest = function StandartJQueryDataTag(oTested)
	{
		var oResult = new TestResult();
		var oMustVals = oTested.data('jqcmbx').DOMElements.holder[0].id;
		var oActualVals = $('#' + oTested.attr('id')).data('jqcmbx').DOMElements.holder[0].id;
		
		oResult.title = 'Standart jQuery `data-jqcmbx` tag';
		oResult.must = oMustVals;
		oResult.actual = oActualVals;
		return oResult;
	};
	aTests.push(unitTest);

	return aTests;
}